#+_+ coding:utf-8 +_+
import xml.etree.ElementTree as ET
import time
from message import XMLMessage

class TextMsg(XMLMessage):
    msg = "2"
    def Deal(self):
        return self.respond()

    def respond(self):
        rspXMLTpl = """
<xml>
<ToUserName><![CDATA[{toUser}]]></ToUserName>
<FromUserName><![CDATA[{fromUser}]]></FromUserName>
<CreateTime>{createTime}</CreateTime>
<MsgType><![CDATA[{msgType}]]></MsgType>
<Content><![CDATA[{msgCnt}]]></Content>
</xml>
        """
        rspXML = rspXMLTpl.format(toUser=self.attrs["FromUserName"],
                                  fromUser = self.attrs["ToUserName"],
                                  createTime=str(time.time()),
                                  msgType = "text",
                                  msgCnt  = self.msg
                            
        )

        return rspXML.strip()
